﻿using System;
using ebc.coordinator.contract;
using ebc.message.contract;

namespace ebc.coordinator {
    public class Coordinator : ICoordinator {

        public void ProcessCoordinatorRequest(string request, Action<string> processResult) {

            request = request + "=>InputRequest Coordinator\t<=CoordinatorRequest=>" + Environment.NewLine +
                "=>OutputRequest Coordiator event OnWorker\t<=WorkerRequest=>" + Environment.NewLine;

            OnWorker.Request(request).Receive(r =>
            {
                r = r + "=>InputResult Coordinator\t<=WorkerResult=>" + Environment.NewLine +
                        "=>OutputResult Coordinator\t<=CoordinatorResult=>" + Environment.NewLine;
                processResult(r);
            });
        }

        public event Request<string, string> OnWorker;
    }
}